package com.xsjl.qa.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xsjl.qa.mapper.ReplyMapper;
import com.xsjl.qa.pojo.Reply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * reply服务层
 * 
 * @author Administrator
 *
 */
@Service
public class ReplyService {

	@Autowired
	private ReplyMapper replyMapper;
	

	/**
	 * 查询全部列表
	 * @return
	 */
	public List<Reply> findAll() {
		return replyMapper.selectList(null);
	}

	
	/**
	 * 条件查询+分页
	 * @param whereMap
	 * @param page
	 * @param size
	 * @return
	 */
	public Page<Reply> findSearch(Map whereMap, int page, int size) {
		Page<Reply> pages = new Page<>(page, size);
		QueryWrapper<Reply> wrapper = new QueryWrapper<>();
		wrapper.allEq(whereMap);
		return replyMapper.selectPage(pages, wrapper);
	}

	
	/**
	 * 条件查询
	 * @param whereMap
	 * @return
	 */
	public List<Reply> findSearch(Map whereMap) {
		QueryWrapper<Reply> wrapper = new QueryWrapper<>();
		wrapper.allEq(whereMap);
		return replyMapper.selectList(wrapper);
	}

	/**
	 * 根据ID查询实体
	 * @param id
	 * @return
	 */
	public Reply findById(String id) {
		return replyMapper.selectById(id);
	}

	/**
	 * 增加
	 * @param reply
	 */
	public void add(Reply reply) {
		replyMapper.insert(reply);
	}

	/**
	 * 修改
	 * @param reply
	 */
	public void update(Reply reply) {
		replyMapper.updateById(reply);
	}

	/**
	 * 删除
	 * @param id
	 */
	public void deleteById(String id) {
		replyMapper.deleteById(id);
	}


}
